package com.mongodb.application.service.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.mongodb.application.dao.user.UserDao;
import com.mongodb.application.entity.user.UserEntity;
import com.mongodb.application.service.user.UserService;
import com.mongodb.application.utils.BaseReturn;

@Service
public class UserServiceImpl implements UserService{
	
	@Autowired
    private UserDao userDao;
	
	
	@Override
	public BaseReturn findAll() {
		BaseReturn result = new BaseReturn("1","成功",userDao.findAll());
		return result;
	}

	@Override
	public BaseReturn getUser(String id) {
		BaseReturn result = new BaseReturn("1","成功",userDao.getUser(id));
		return result;
	}

	@Override
	public BaseReturn update(UserEntity user) {
		userDao.update(user);
		BaseReturn result = new BaseReturn("1","成功","");
		return result;
	}

	@Override
	public BaseReturn insert(UserEntity user) {
		userDao.insert(user);
		BaseReturn result = new BaseReturn("1","成功","");
		return result;
	}

	@Override
	public BaseReturn insertAll(List<UserEntity> users) {
		userDao.insertAll(users);
		BaseReturn result = new BaseReturn("1","成功","");
		return result;
	}

	@Override
	public BaseReturn remove(Integer id) {
		userDao.remove(id);
		BaseReturn result = new BaseReturn("1","成功","");
		return result;
	}

	@Override
	public BaseReturn findByPage(UserEntity user, Pageable pageable) {
		BaseReturn result = new BaseReturn("1","成功",userDao.findByPage(user, pageable));
		return result;
	}

}
